package routers

import (
	"UpdateManagerServer/controllers"
	"UpdateManagerServer/filters"

	beego "github.com/beego/beego/v2/server/web"
)

func init() {
	// models.Init()
	// models.GlobalCacheMgr.GetCacheFromConf()

	//过滤器
	beego.InsertFilter("/api/*", beego.BeforeRouter, filters.CheckToken)
	beego.Router("/home", &controllers.VersionPageController{})
	beego.Router("/login", &controllers.LoginController{})
	beego.Router("/permission", &controllers.PermissionController{})
	beego.Router("/PageFileList", &controllers.FileListController{})
	beego.Router("/PackgeDownloadList", &controllers.PackDownloadListController{})
	beego.Router("/api/mashine/list", &controllers.MashineListController{}, "get:GetMachineList")
	beego.Router("/api/mashine/create", &controllers.MashineListController{}, "post:PostCreateMachine")
	beego.Router("/api/version/list", &controllers.VersionListController{}, "get:GetVersionList")
	beego.Router("/api/version/max", &controllers.VersionListController{}, "get:GetVersionMax")
	beego.Router("/api/version/get", &controllers.VersionListController{}, "get:GetVersionInfoByID")
	beego.Router("/api/version/create", &controllers.VersionListController{}, "post:PostAddVersion")
	beego.Router("/api/version/delete", &controllers.VersionListController{}, "post:PostDeleteVersion")
	beego.Router("/api/version/add_subversion", &controllers.VersionListController{}, "post:PostAddSubVersion")
	beego.Router("/api/download", &controllers.FileController{}, "post:DownloadFileEx")
	beego.Router("/api/file/list", &controllers.FileController{}, "post:PostFileList")     // 文件目录接口
	beego.Router("/api/file/listAll", &controllers.FileController{}, "get:GetFileListALL") //递归获取文件列表
	beego.Router("/api/file/delete", &controllers.FileController{}, "post:DeletFileDoc")   // 删除文件和文件夹
	beego.Router("/api/file/rename", &controllers.FileController{}, "post:RenameFile")
	beego.Router("/api/upload/chunk", &controllers.UploadController{}, "post:PostChunk")
	beego.Router("/api/upload/merge", &controllers.UploadController{}, "post:PostMerge")
	beego.Router("/api/login", &controllers.AuthController{}, "post:Login")
	beego.Router("/api/register", &controllers.UserController{}, "post:Register")
	beego.Router("/api/employee/info", &controllers.UserController{}, "get:GetEmployeeInfo")
	beego.Router("/api/employee/list", &controllers.UserController{}, "get:GetEmployeeList")
	beego.Router("/api/employee/update", &controllers.UserController{}, "post:PostEmployeeUpdate")
}
